package com.lt.test.consumer.web.util;

import com.lt.test.common.exception.CustomException;
import com.lt.test.common.util.CustomUtil;
import com.lt.test.common.util.StringUtils;
import com.lt.test.entity.DTO.ActiveUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

import java.util.Map;

public class WebUtils {


    /**
     * 针对页面传递过来的相关信息进行处理
     *
     * @param stringMap
     * @throws CustomException
     */
    public static void managerStringMap(Map<String, String> stringMap) throws CustomException {
        Subject subject = SecurityUtils.getSubject();
        ActiveUser activeUser = (ActiveUser) subject.getPrincipal();
        //实际上是市级--安顺，毕节，六盘水
        if (!StringUtils.isNullOrTrimEmpty(activeUser.getChannelName())) {
            stringMap.put("fiveChannelCode", CustomUtil.getChannelCodePreFive(activeUser.getChannelName()));
        }

        //区县处理
        if (!StringUtils.isNullOrTrimEmpty(activeUser.getQuXianName())) {
            stringMap.put("quXianName", activeUser.getQuXianName());
        }

        //渠道处理
        if (!StringUtils.isNullOrTrimEmpty(activeUser.getRealChannelName())) {
            stringMap.put("channelName", activeUser.getRealChannelName());
        }
        //客户经理处理
        if (!StringUtils.isNullOrTrimEmpty(activeUser.getEmpName())) {
            stringMap.put("empName", activeUser.getEmpName());
        }
    }
}
